<?php
/*
 * 核销码
 */
$args 	= C('get');
$openid = C('openid');
$code 	= @$args['cpcode'];
if(empty($code)) exit('code error');

$userService  = loadService('User');
$adminService = loadService('Admin');

// 校验码
$userid = $userService->code2n($code);
if(!$userid) message('校验有误');

// 校验用户
$user = $userService->getById($userid);
if(empty($user)) exit('user error 101');
if($user['codestatus']!=1) message('已经核销');

// 校验admin
$isAdmin = $adminService->isLogedByOpenid($openid);
if(!$isAdmin) message('没有权限');

// 核销
$admin = $adminService->getByOpenid($openid);
if(!$userService->logicCheckById($userid, $admin['id'])) message('权限有误');

message('核销成功');
loadView(); // 默认加载同名
?>
